home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: EU.net!sun4nl!news
- From: vdkamp@inter.nl.net (Peter H.J. van der Kamp)
- Subject: Problem with SEEKG
- X-Nntp-Posting-Host: asp99-21.amsterdam.nl.net
- Content-Type: Text/Plain; charset=US-ASCII
- Message-ID: <DKvpAn.MB6@inter.NL.net>
- Sender: news@inter.NL.net (News at news)
- Organization: VDK
- X-Newsreader: WinVN 0.99.6
- Mime-Version: 1.0
- Date: Mon, 8 Jan 1996 20:08:47 GMT
-
- Hello all,
-
- I have problems with seekg. In my program I have two functions: one reads a
- file sequential, the other reads the file random.
- Code for function one:
- char *stationsfile = "d:\\stations.dat";
- stations.open(stationsfile, ios::in);
- stations.getline(record,recordlengte);
- while (!stations.eof())
- { ....
- stations.getline(record,recordlengte);
- }
- stations.close();
- stations.clear(ios::goodbit);
-
- This works fine.
-
- Code for function two:
- char *stationsfile = "d:\\stations.dat";
- stations.open(stationsfile, ios::in | ios::binary);
- stations.seekg(0, ios::end);
-
- Via the debugger I can see that the file is opened correctly, but I get an
- GPF on seekg.
- I tried the following:
- seekg(1);
- seekg(1, ios::beg);
- seekg(-1, ios::end);
- but that didn't solve the GPF. According to my C++ books this code ought to
- be right, but at the moment I'm not such an experienced C++ programmer, so
- what do I wrong?
- Environment: DOS 6.0, Windows 3.1, Borland Turbo C++ for Windows 3.1.
-
- --Peter van der Kamp
-
-